package com.woniu.service.command;

import com.woniu.inlet.web.fo.CouponFo;
import com.woniu.outlet.mysql.po.UserCoupon;
import com.woniu.utils.ApplicationContextHolder;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
public class CouponPayCommand {
    private Integer userId;
    private BigDecimal money;
    private CouponPayCommandHandle handle;

    public CouponPayCommand() {
        this.handle = ApplicationContextHolder.getApplicationContext().getBean(CouponPayCommandHandle.class);
    }

    public CouponPayCommand(Integer userId, BigDecimal money) {
        this();
        this.userId = userId;
        this.money = money;
    }

    public List<UserCoupon> excute() {
        return handle.checkCoupon(this);
    }
}
